package com.itheima.array;

public class DyadicArray {

    public static void main(String[] args) {

        printArr1();
        System.out.println("============");
        printArr2();

    }

    //静态初始化二维数组并打印
    public static void printArr1() {
        int[][] arr = {
                {1, 2, 3},
                {4, 5, 6, 55},
                {7, 8, 9, 66, 87}
        };
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j] + "\t");
            }
            System.out.println();
        }
    }

    //动态初始化二维数组并打印
    public static void printArr2() {
        int[][] arr = new int[3][5];
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                arr[i][j] = (int) (Math.random() * 100);
            }
        }
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j] + "\t");
            }
            System.out.println();
        }
    }

}
